package com.local.service.impl;

import com.base.dao.DAO;
import com.base.util.PageData;

import com.local.service.PersonalManager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lee on 2016/6/24.
 */
@Service("personalService")
public class PersonalServiceImpl implements PersonalManager {

    @Resource(name = "daoSupport")
    private DAO daoSupport;

    //工资
    public List<PageData> getSalary(PageData pd) {
        List<PageData> salaryList = new ArrayList<PageData>();

        try {
            salaryList = (List<PageData>) daoSupport.findForList("PersonalInfoMapper.getSalary",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return salaryList;
    }

    public void insertSalery(PageData pd) {
        try {
            daoSupport.save("PersonalInfoMapper.insSalary",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSalary(PageData pd){
        try {
            daoSupport.delete("PersonalInfoMapper.delSalary",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSalary(PageData pd){
        try {
            daoSupport.update("PersonalInfoMapper.updSalary",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public PageData getSalaryByID(PageData pd){
        PageData result = new PageData();
        try {
            result = (PageData) daoSupport.findForObject("PersonalInfoMapper.getSalaryByID",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    //劳务
    public List<PageData> getLaowu(PageData pd) {
        List<PageData> laowu = new ArrayList<PageData>();
        try {
            laowu = (List<PageData>) daoSupport.findForList("LaowuMapper.getLaowu",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return laowu;
    }

    public void insertLaowu(PageData pd) {
        try {
            daoSupport.save("LaowuMapper.insLaowu",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void deleteLaowu(PageData pd){
        try {
            daoSupport.delete("LaowuMapper.delLaowu",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public PageData getLaowuByID(PageData pd){
        PageData laowu = new PageData();
        try {
            laowu = (PageData) daoSupport.findForObject("LaowuMapper.getLaowuByID",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return laowu;
    }

    public void updateLaowu(PageData pd){
        try {
            daoSupport.update("LaowuMapper.updLaowu",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //房产
    public List<PageData> getHouse(PageData pd) {
        List<PageData> house = new ArrayList<PageData>();

        try {
            house = (List<PageData>) daoSupport.findForList("PersonalInfoMapper.getHouse",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return house;
    }

    public void insertHouse(PageData pd) {
        try {
            daoSupport.save("PersonalInfoMapper.insHouse",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteHouse(PageData pd){
        try {
            daoSupport.delete("PersonalInfoMapper.delHouse",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public PageData getHouseByID(PageData pd){
        PageData house = new PageData();
        try {
            house = (PageData) daoSupport.findForObject("PersonalInfoMapper.getHouseByID",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return house;
    }

    public void updateHouse(PageData pd){
        try {
            daoSupport.update("PersonalInfoMapper.updHouse",pd);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
